<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register backend routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "backend" middleware group. Enjoy building your backend!
|
*/
Route::get('data/screen', 'DataController@screenData')->name('data.screenData');
Route::apiResource('tokens','TokenController');
Route::apiResource('check-order','CheckOrderController');
Route::group(['middleware' => ['auth:school']],function () {

    Route::post('school-admins/modify-password','SchoolAdminController@modifyPassword')->name('school-admins.modifyPassword');

    Route::apiResources([
        'data'=> 'DataController',
        'self'=> 'SelfController',
        'uploads'=>'UploadController',
    ]);
});

Route::group(['middleware' => ['auth:school','permission']],function () {

    Route::put('school-admins/refresh-password/{admin}','SchoolAdminController@refreshPassword')->name('school-admins.refreshPassword');

    Route::put('book-rules/{id}/settle','BookRuleController@settle')->name('book-rules.settle');

    Route::apiResources([
        'roles' => 'RoleController',
        'school-rules' => 'SchoolRuleController',
        'school-admins' => 'SchoolAdminController',
        'users' => 'UserController',
        'user-roles' => 'UserRoleController',
        'school-admin-logs' => 'SchoolAdminLogController',
        'schools' => 'SchoolController',
        'foods' => 'FoodController',
        'food-types' => 'FoodTypeController',
        'book-rules' => 'BookRuleController',
        'price-categories' => 'PriceCategoryController',
        'book-rule-prices' => 'BookRulePriceController',
        'book-orders' => 'BookOrderController',
        'order-statistics' => 'OrderStatisticsController',
        'meal-statistics' => 'MealStatisticsController',
        'order-reviews' => 'OrderReviewController',
        'import-users' => 'ImportUserController'
    ]);
});
